﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using Jumbot.Common;
using Jumbot.DataOper;
namespace JumbotCms.DataObject
{
    /// <summary>
    /// 用户组表信息
    /// </summary>
    public class UserGroup
    {
        private string m_Id = "0";
        private string m_GroupName = string.Empty;
        private string m_Setting = string.Empty;
        private int m_IsLogin = 0;
        private int m_UserTotal = 0;

        public string Id
        {
            get { return m_Id; }
            set { m_Id = value; }
        }
        public string GroupName
        {
            set { m_GroupName = value; }
            get { return m_GroupName; }
        }
        public string Setting
        {
            set { m_Setting = value; }
            get { return m_Setting; }
        }
        public int IsLogin
        {
            set { m_IsLogin = value; }
            get { return m_IsLogin; }
        }
        public int UserTotal
        {
            set { m_UserTotal = value; }
            get { return m_UserTotal; }
        }

        public UserGroup()
        {}
        public void GetAllColumn(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT * FROM [jcms_normal_usergroup] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                Id = _id;
                GroupName = dr["GroupName"].ToString();
                Setting = dr["Setting"].ToString();
                IsLogin = Validator.StrToInt(dr["IsLogin"].ToString(), 0);
                UserTotal = Validator.StrToInt(dr["UserTotal"].ToString(), 0);
            }
        }

        public string GetGroupName(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [GroupName] FROM [jcms_normal_usergroup] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["GroupName"].ToString();
            }
            return string.Empty;
        }
        public string GetSetting(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Setting] FROM [jcms_normal_usergroup] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["Setting"].ToString();
            }
            return string.Empty;
        }
        public int GetIsLogin(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [IsLogin] FROM [jcms_normal_usergroup] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToInt(dt.Rows[0]["IsLogin"].ToString(), 0);
            }
            return 0;
        }
        public int GetUserTotal(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [UserTotal] FROM [jcms_normal_usergroup] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToInt(dt.Rows[0]["UserTotal"].ToString(), 0);
            }
            return 0;
        }

    }
}
